clear all

use Master2018.dta


// The following is collapsed at the overall session of LS and RS level


replace both_overall = both_overall[_n-1] if missing(both_overall)
#delimit ;
collapse
(first)
LSmaj RSmaj LegisMaj onlyLSmaj onlyRSmaj PMmandate govt_type prime_minister bicam_type
totalloksabha mainpartygovtseats mainoppositionseats coalitionpartners
date longdate dayofweek day2 dateinmonth month month_id year yr_bef_elec
noofbillspassedbybothhousesofpar
loksabhainsession sessionwithinloksabha effectpartseat effectpartvote cong_govt frac_slp
(sum)
totalordinances = ordinances
session_length = bothinsession
break_length = bothinbreak
, by(both_overall);
#delimit cr

rename date date1

gen date = (date1 - 31910) / 3650

program regx, eclass
	version 14
	syntax varlist(min=2 fv) [if] [in], robust [Test(string)] [TEST2(string)] [TEST3(string)] [TEST4(string)] [YMEAN(string)] [*]
	reg `varlist' `if' `in', robust `options'
	if "`test'" != "" {
		test `test'
		ereturn local test_cmd `test'
		ereturn scalar test_p = r(p)
	}
	if "`test2'" != "" {
		test `test2'
		ereturn local test2_cmd `test2'
		ereturn scalar test2_p = r(p)
	}
	if "`test3'" != "" {
		test `test3'
		ereturn local test3_cmd `test3'
		ereturn scalar test3_p = r(p)
	}
end

label drop govt_type

#delimit ;
label define govt_type
0 "Single Party Majority"
1 "Single Party Minority" 
2 "Majority Party Coalition" 
3 "Minority Coalition" 
;
#delimit cr

label drop bicam_type

#delimit ;
label define bicam_type
0 "Bicameral Majority"
1 "Minority in Both" 
2 "Only Minority in RS" 
3 "Only Minority in LS"
;
#delimit cr

label values bicam_type bicam_type

gen post_1985 = 0
replace post_1985 = 1 if date1 >=31776 //Wadhwa decision 20th Dec 1986



label var post_1985 "Post 1986"
label values govt_type govt_type
label var noofbillspassedbybothhousesofpar "Number of Acts"
label var break_length "Length of Break"
label var LSmaj "LS Majority"
label var LegisMaj "Bicameral majority"



label var yr_bef_elec "Yr before  election"
label var effectpartvote "Effective num parties"
label var cong_govt "Congress govt"
label var date "Linear time trend"

local session_ctls "break_length session_length i.sessionwithinloksabha"
local pol_ctls "yr_bef_elec effectpartvote cong_govt"

// The next 5 lines replicate the regressions in Table 4 from the paper
eststo moreords_1: reg totalordinances LegisMaj, robust
eststo moreords_2: reg totalordinances LegisMaj i.month_id, robust
eststo moreords_3: reg totalordinances LegisMaj `session_ctls'  i.month_id, robust
eststo moreords_4: reg totalordinances LegisMaj `session_ctls' `pol_ctls' i.month_id, robust
eststo moreords_5: reg totalordinances LegisMaj `session_ctls' `pol_ctls' i.month_id date, robust

eststo LS_moreords_1: reg totalordinances LSmaj, robust
eststo LS_moreords_2: reg totalordinances LSmaj i.month_id, robust
eststo LS_moreords_3: reg totalordinances LSmaj `session_ctls' i.month_id, robust
eststo LS_moreords_4: reg totalordinances LSmaj `session_ctls' `pol_ctls' i.month_id, robust
eststo LS_moreords_5: reg totalordinances LSmaj `session_ctls' `pol_ctls' i.month_id date, robust


eststo LSmaj_moreords_1: reg totalordinances LSmaj if RSmaj == 0, robust
eststo LSmaj_moreords_2: reg totalordinances LSmaj i.month_id if RSmaj == 0, robust
eststo LSmaj_moreords_3: reg totalordinances LSmaj `session_ctls' i.month_id if RSmaj == 0, robust
eststo LSmaj_moreords_4: reg totalordinances LSmaj `session_ctls' `pol_ctls' i.month_id if RSmaj == 0, robust
eststo LSmaj_moreords_5: reg totalordinances LSmaj `session_ctls' `pol_ctls' i.month_id date if RSmaj == 0, robust



eststo TS_pre_ords_1: reg totalordinances LegisMaj   if post_1985 == 0, robust 
eststo TS_pre_ords_2: reg totalordinances LegisMaj  i.month_id if post_1985 == 0, robust
eststo TS_pre_ords_3: reg totalordinances LegisMaj  `session_ctls'  i.month_id if post_1985 == 0, robust
eststo TS_pre_ords_4: reg totalordinances LegisMaj  `session_ctls' `pol_ctls' i.month_id if post_1985 == 0, robust
eststo TS_pre_ords_5: reg totalordinances LegisMaj  `session_ctls' `pol_ctls' i.month_id date if post_1985 == 0, robust

eststo TS_pst_ords_1: reg totalordinances LegisMaj   if post_1985 == 1, robust 
eststo TS_pst_ords_2: reg totalordinances LegisMaj  i.month_id if post_1985 == 1, robust
eststo TS_pst_ords_3: reg totalordinances LegisMaj  `session_ctls'  i.month_id if post_1985 == 1, robust
eststo TS_pst_ords_4: reg totalordinances LegisMaj  `session_ctls' `pol_ctls' i.month_id if post_1985 == 1, robust
eststo TS_pst_ords_5: reg totalordinances LegisMaj  `session_ctls' `pol_ctls' i.month_id date if post_1985 == 1, robust

eststo type_moreords_1: regx totalordinances i.govt_type, robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_moreords_2: regx totalordinances i.govt_type `session_ctls', robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_moreords_3: regx totalordinances i.govt_type i.month_id, robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_moreords_4: regx totalordinances i.govt_type i.month_id `session_ctls', robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_moreords_5: regx totalordinances i.govt_type i.month_id `session_ctls' `pol_ctls' , robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_moreords_6: regx totalordinances i.govt_type i.month_id `session_ctls' `pol_ctls' date, robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)

eststo bicam_type_moreords_1: regx totalordinances i.bicam_type, robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_moreords_2: regx totalordinances i.bicam_type `session_ctls', robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_moreords_3: regx totalordinances i.bicam_type i.month_id, robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_moreords_4: regx totalordinances i.bicam_type i.month_id `session_ctls', robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_moreords_5: regx totalordinances i.bicam_type i.month_id `session_ctls' `pol_ctls' , robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_moreords_6: regx totalordinances i.bicam_type i.month_id `session_ctls' `pol_ctls' date, robust test(1.bicam_type = 2.bicam_type) 





#delimit ;
local common_tab_opts
star(* 0.1 ** 0.05 *** 0.01)
varwidth(30) modelwidth(10) wrap se r2 nobase noomitted 
label numbers nodepvars
;
#delimit cr

local all_tab_opts		`common_tab_opts' indicate("Month dummies = *.month_id" "Session controls = break_length session_length *.sessionwithinloksabha")


esttab moreords_* , `all_tab_opts' nomtitles replace
esttab LS_moreords_* , `all_tab_opts' nomtitles replace
esttab type_moreords_*		, `all_tab_opts' nomtitles  scalar("test_p \$p\$-value \$H_0^1: \gamma_1 = \gamma_2\$" "test2_p \$p\$-value \$H_0^2: \gamma_1 = \gamma_3\$"  "test3_p \$p\$-value \$H_0^3: \gamma_2 = \gamma_3\$" ) sfmt(3)
esttab TS_pre_ords_* , `all_tab_opts' nomtitles replace
esttab TS_pst_ords_* , `all_tab_opts' nomtitles replace

esttab LSmaj_moreords_* , `all_tab_opts' nomtitles replace
esttab bicam_type_moreords_*		, `all_tab_opts' nomtitles  scalar("test_p \$p\$-value \$H_0^1: \gamma_1 = \gamma_2\$") sfmt(3)


//Latex

esttab moreords_* 	 	using "tables/moreords.tex" , `all_tab_opts' nomtitles replace
esttab TS_pre_ords_* 	using "tables/TS_pre_ords.tex" , `all_tab_opts' nomtitles replace
esttab TS_pst_ords_* 	using "tables/TS_pst_ords.tex" , `all_tab_opts' nomtitles replace
esttab LS_moreords_* 	using "tables/LS_moreords.tex" , `all_tab_opts' nomtitles replace
esttab type_moreords_*	using "tables/type_moreords.tex" , `all_tab_opts' nomtitles  scalar("test_p \$p\$-value \$H_0^1: \gamma_1 = \gamma_2\$" "test2_p \$p\$-value \$H_0^2: \gamma_1 = \gamma_3\$"  "test3_p \$p\$-value \$H_0^3: \gamma_2 = \gamma_3\$" ) sfmt(3) substitute(\_ _) replace
esttab bicam_type_moreords_*	using "tables/bicam_type_moreords.tex" , `all_tab_opts' nomtitles  scalar("test_p \$p\$-value \$H_0^1: \gamma_1 = \gamma_2\$") sfmt(3) substitute(\_ _) replace
